﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using soho.Library;

public partial class CRMAccountBalance : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            if (Session[GeneralUsage.CurrentUser] != null)
            {
                string username = ((Customer)Session[GeneralUsage.CurrentUser]).UserName;
                string path = System.IO.Path.Combine(Request.PhysicalApplicationPath, @"CustomerFiles\" + username);

                string[] fileEntries = Directory.GetFiles(path);
                foreach (string fullPath in fileEntries)
                {
                    string[] temp = fullPath.Split(@"\".ToCharArray()[0]);
                    string fileName = temp[temp.Length-1];

                    HyperLink hl = new HyperLink();
                    hl.Text = fileName;
                    hl.NavigateUrl = Request.ApplicationPath + @"\CustomerFiles\" + username + @"\" + fileName;

                    TableCell tc = new TableCell();
                    tc.Controls.Add(hl);
                   
                    TableRow tr = new TableRow();
                    tr.Cells.Add(tc);
                    
                    tbFileList.Rows.Add(tr);
                }
            }
            else
            {
                Response.Redirect(".");
            }
        }
    }
}